import {mapState, useStore} from "vuex";
import {computed} from "vue";

export default function useState(name, item) {
    const store = useStore()
    const storeStateFns = {...mapState(name, item)}
    const storeState = {}
    Object.keys(storeStateFns).forEach(keyName => {
        let fn = storeStateFns[keyName].bind({$store: store})
        storeState[keyName] = computed(fn)
    })
    return storeState
}